package com.dianrui.agent.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.dianrui.agent.R;
import com.dianrui.agent.fragment.OrderCarFinishFragment;
import com.dianrui.agent.fragment.OrderCarPauseFragment;
import com.dianrui.agent.fragment.OrderCarProgressFragment;
import com.dianrui.agent.fragment.OrderCarUnPayFragment;


public class OrderListPageAdapter extends FragmentPagerAdapter {
    private String[] mTitles = new String[]{"进行中","暂停","未付款","已完成"};
    private Context context;

    public OrderListPageAdapter(FragmentManager fm,Context context) {
        super(fm);
        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 1) {
            return new OrderCarPauseFragment();
        } else if (position == 2) {
            return new OrderCarUnPayFragment();
        } else if (position == 3) {
            return new OrderCarFinishFragment();
        }
        return new OrderCarProgressFragment();

    }

    public View getTabView(int position) {
        View tabView = LayoutInflater.from(context).inflate(R.layout.order_tab_item_txt, null);
        TextView textView = tabView.findViewById(R.id.show_tab_title);
        textView.setText(mTitles[position]);
        return tabView;
    }

    @Override
    public int getCount() {
        return mTitles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position];
    }
}
